home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / jcool01.zip / EX4_7.C < prev    next >
C/C++ Source or Header  |  1992-08-20  |  2KB  |  41 lines

  1. //
  2. // Copyright (C) 1991 Texas Instruments Incorporated.
  3. //
  4. // Permission is granted to any individual or institution to use, copy, modify,
  5. // and distribute this software, provided that this complete copyright and
  6. // permission notice is maintained, intact, in all copies and supporting
  7. // documentation.
  8. //
  9. // Texas Instruments Incorporated provides this software "as is" without
  10. // express or implied warranty.
  11. //
  12.  
  13. #include <cool/Date_Time.h>            // Include Date_Time class
  14.  
  15.  
  16. int main (void) {
  17.   set_default_country (UNITED_STATES);        // Set default country code
  18.   set_default_time_zone (US_CENTRAL);        // Set default time zone
  19.   CoolDate_Time d1;                // Create CoolDate_Time object
  20.   d1.set_local_time ();                // Set current system time
  21.   cout << "Local date/time is: " << d1 << "\n";    // Output date in US format
  22.   d1.set_country (UNITED_KINGDOM);        // Set country to UK
  23.   d1.set_time_zone (GB_EIRE);            // Set Greenwich Mean Time
  24.   cout << "GMT date/time is: " << d1 << "\n";    // Output date/time at GMT
  25.   d1.parse("1 April 1890, 4:30pm");        // Parse some date in UK format
  26.   cout << "Date/time parsed is: " << d1 << "\n"; // Output date/time parsed
  27.   d1.set_country (FRANCE);             // Set country to France
  28.   d1.set_time_zone (WET);             // Western European Timezone
  29.   cout << "Date/time in France: " << d1 << "\n"; // Output date/time in France
  30.   CoolDate_Time d2;                 // Create another object
  31.   d2.set_country (UNITED_STATES);         // Set country to US
  32.   d2.set_time_zone (US_MOUNTAIN);         // Set Mountain Timezone
  33.   d2.set_local_time ();                 // Set current system time
  34.   cout << "Date/time set is: " << d2 << "\n";     // Output date in US format
  35.   d2.decr_month (3);                 // Move back three months
  36.   cout << "Date/time three months earlier: " << d2 << "\n"; // Output date
  37.   cout << "Duration between dates is ";                // 
  38.   cout << d1.ascii_duration (d2) << "\n";            // Output time duration
  39.   return 0;                            // Return valid sucess code
  40. }
  41.